package com.mentaleye.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mentaleye.bean.CurriculumTempBean;
import com.mentaleye.dal.dao.CurriculumTempDao;
import com.mentaleye.dal.model.CurriculumTemp;
import com.mentaleye.dal.model.CurriculumTempExample;
import com.mentaleye.service.CurriculumTempService;
import com.mentaleye.util.CommonPage;
import com.mentaleye.util.ObjectUtil;

@Repository
public class CurriculumTempServiceImpl implements CurriculumTempService {

	@Autowired
	private CurriculumTempDao curriculumTempDao;
	
	public CurriculumTempBean getCurriculumTempByNo(Integer curriculumTempNo){
		return (CurriculumTempBean) ObjectUtil.transfer(curriculumTempDao.getCurriculumTempByNo(curriculumTempNo), CurriculumTempBean.class);
	}
	
	public boolean editCurriculumTemp(CurriculumTempBean curriculumTemp, boolean add) {
		boolean result = false;
		CurriculumTemp temp=(CurriculumTemp) ObjectUtil.transfer(curriculumTemp, CurriculumTemp.class);
		if(add){
			result = curriculumTempDao.addCurriculumTemp(temp);
		}else{
			result = curriculumTempDao.editCurriculumTemp(temp);
		}
		return result;
	}

	@SuppressWarnings("unchecked")
	public List<CurriculumTempBean> queryCurriculumTemp(CurriculumTempExample example) {
		return ObjectUtil.transferList(curriculumTempDao.queryCurriculumTemp(example), CurriculumTemp.class);
	}

	@SuppressWarnings("unchecked")
	public void queryCurriculumTempByPage(CommonPage commonPage) {
		List<CurriculumTempBean> data = ObjectUtil.transferList(curriculumTempDao.queryCurriculumTemp(commonPage.pageToMap()), CurriculumTempBean.class);
		commonPage.setPageData(data);
	}

	public boolean deleteCurriculumTemp(List<Integer> ids) {
		return curriculumTempDao.deleteCurriculumTemp(ids);
	}

	public boolean updateRlate(Integer cno, Integer tmpNo, Integer sort) {
		return curriculumTempDao.updateRlate(cno, tmpNo, sort);
	}

	public boolean saveRlate(Integer cno, Integer tmpNo, Integer sort) {
		return curriculumTempDao.saveRlate(cno, tmpNo, sort);
	}

	public boolean deleteRlate(List<Integer> ids, Integer tmpNo) {
		return curriculumTempDao.deleteRlate(ids, tmpNo);
	}
	
	@SuppressWarnings("unchecked")
	public List<CurriculumTempBean> queryByExample(CurriculumTempExample example){
		return ObjectUtil.transferList(curriculumTempDao.selectByExample(example), CurriculumTempBean.class);
	}

}
